var e = require("../../@babel/runtime/helpers/interopRequireDefault"), t = e(require("../../@babel/runtime/regenerator")), r = require("../../@babel/runtime/helpers/createForOfIteratorHelper"), a = require("../../@babel/runtime/helpers/asyncToGenerator"), i = e(require("../../http/offlineShop")), n = require("../../utils/tool"), o = e(require("../../behavior/orderBehavior")), s = new i.default();

Page({
    behaviors: [ o.default ],
    data: {
        orderId: "",
        details: {},
        status: [ "未付款", "已关闭", "待出货", "已完成", "已退款", "退款中" ]
    },
    onLoad: function(e) {
        this.setData({
            orderId: e.orderId
        });
    },
    toGoodsDetails: function(e) {
        var t = e.currentTarget.dataset.productid;
        0 == e.currentTarget.dataset.producttype ? wx.navigateTo({
            url: "/pages/direct-buy-details/direct-buy-details?productId=".concat(t)
        }) : wx.navigateTo({
            url: "/pages/series/series?productId=".concat(t)
        });
    },
    getDetail: function() {
        var e = this;
        return a(t.default.mark(function a() {
            var i, o, u, d, c;
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    return t.prev = 0, wx.showLoading({
                        title: "加载中",
                        mask: !0
                    }), i = {
                        orderId: e.data.orderId
                    }, t.next = 5, s.offlineShopOrderDetails(i);

                  case 5:
                    (o = t.sent).data.discount = o.data.couponAmount || o.data.activityAmount, u = !1, 
                    d = r(o.data.orderItemVoList), t.prev = 9, d.s();

                  case 11:
                    if ((c = d.n()).done) {
                        t.next = 18;
                        break;
                    }
                    if (1 != c.value.status) {
                        t.next = 16;
                        break;
                    }
                    return u = !0, t.abrupt("break", 18);

                  case 16:
                    t.next = 11;
                    break;

                  case 18:
                    t.next = 23;
                    break;

                  case 20:
                    t.prev = 20, t.t0 = t.catch(9), d.e(t.t0);

                  case 23:
                    return t.prev = 23, d.f(), t.finish(23);

                  case 26:
                    e.setData({
                        title: e.getShopOrderStatusTitle(o.data.orderStatus),
                        hasRefund: u,
                        details: o.data
                    }), t.next = 32;
                    break;

                  case 29:
                    t.prev = 29, t.t1 = t.catch(0), (0, n.toastToPage)(t.t1.msg);

                  case 32:
                    return t.prev = 32, wx.hideLoading(), t.finish(32);

                  case 35:
                  case "end":
                    return t.stop();
                }
            }, a, null, [ [ 0, 29, 32, 35 ], [ 9, 20, 23, 26 ] ]);
        }))();
    },
    onShow: function() {
        this.getDetail();
    }
});